﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ChaosEngine.EngineCore;
using ChaosEngine.GPU.Core;
namespace ExampleTemplateEmbeded
{
    public partial class Form1 : Form
    {

        /// <summary>
        /// The raw api-dependent gpu core. NEVER(It wont compile) cross your streams. wait. ghostbusters flashback. never create the base level vGpuCore class, create one of the api implentations contained in ChaosEngine.GPU.Api
        /// </summary>
        public vGPUCore GPU = null;

        public Timer RenTime;

        public VividApp App;

        public Form1()
        {
            InitializeComponent();


            //This function is defined in THIS demo, not the actual engine, see below. It initializes the dirext11 graphics api.
            InitGPU("DX10");

            GPU.EmbedCore(panel1, "ExampleEmebed1");
            RenTime = new Timer();
            RenTime.Interval = (1000 / 30);
            RenTime.Tick += new EventHandler(Tick_Render);
            RenTime.Enabled = true;
        }

        public void Tick_Render(object own,EventArgs arg){

            GPU.EmbedBeginDraw();

            GPU.EmbedEndDraw();

        }

        private void InitGPU(string api)
        {
            RegisterGPUPrototypes(); // Ripped from the main engine source, just to show you how it is done.
            GPU = VividApp.GPU.Map[api].SpawnInstance();

            GPU.InitCore();

            App = new VividApp("VividViewer", GPU, true);

        }

        private void RegisterGPUPrototypes()
        {


            VividApp.GPU.Map.Add("DX10", new ChaosEngine.GPU.API.DirectX.GCDX10());
            VividApp.GPU.Map.Add("DX11", new ChaosEngine.GPU.API.DirectX.GCDX11());

        }

    }

}
